//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    imgUrls: [ 
      '/resources/tu1.png',  
      '/resources/tu1.png',
      '/resources/tu1.png'
    ],
    indicatorDots: false,
    autoplay: true,
    interval: 3000,
    duration: 500,
    circular: true,//从data开始的值到此是轮播
    hasUserInfo: false,//是否已授权
  },
  onLoad: function (options) {

  },
  /**
  * 生命周期函数--监听页面初次渲染完成
  */
  onReady: function () {

  },
  /**
  * 生命周期函数--监听页面显示
  */
  onShow: function () {
    this.shuju();//每次进入时数据渲染
  },

  // 搜索查询
  toSearch: function (e) {
   
  },
  // 缴费规则
  tapRule: function (e) {
    wx.navigateTo({
      url: "/pages/payment/rule/rule"
    })
  },
  //绑定会员
  tapBindmember: function (e) {
    this.data.simpleKeyboard.hide()
    wx.navigateTo({
      url: "/pages/w_my_bind_member/w_my_bind_member"
    })
  },
 
  //卷码扫描
  scan: function () {
    var that = this;
    var show;
    wx.scanCode({
      success: (res) => {
        this.show = "--result:" + res.result 
        that.setData({
          show: this.show
        })
        wx.showToast({
          title: '成功',
          icon: 'success',
          duration: 2000
        })
        //获取成功向后台保存获取的值
      },
      fail: (res) => {
        wx.showModal({
          title: "未获取成功",
          content: "未成功扫描二维码",
          confirmColor: "#4fafc9",
          confirmText: "我知道了",
          showCancel: false,
        })
        // wx.showToast({
        //   title: '未获取成功',
        //   image: '/images/tishi.png',
        //   duration: 2000
        // })
      },
      complete: (res) => {
      }  
    })
  },
  //显示对话框
  showModal: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  //隐藏对话框
  hideModal: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },
  //每次进入时数据渲染
  shuju:function(){
    var str2="";
    if (app.globalData.member_tel){
      var str = app.globalData.member_tel;
      str2 = str.substr(0, 3) + "****" + str.substr(7);
    }
    this.setData({
      member: app.globalData.member,
      member_tel: str2,
      member_dengji: app.globalData.member_dengji,
      history: app.globalData.history,
    })
  },
})
